
            <div  id="mainopen">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">产品复制</h4>
            </div>
            <input type="hidden" name="" id="did" ref="didput" value="{$id}">
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <div class="alert alert-dismissable alert-info">
                            <button type="button" class="close">×</button> 
                            <p></p>
                        </div>
                    </div>
                </div>

               <div class="row">
                    <div class="col-md-12">
                        <ul class="nav nav-tabs">
                            <li :class="{'active':index==0}" v-for="(item,index) in langs">
                                <a href="#home" data-toggle="tab">{{item.name}}</a>
                            </li>
                        </ul>
                    </div>
                </div>
            	<div class="row" style="padding-top:10px">
                    <div class="col-md-12">
                    	<table class="table table-striped">
                        	<tr>
                            	<td class="field-name">{:strtoupper(lang("brand"))}</td>
                                <td>
                                	<select class="form-control" v-model="checkRead.brand_id" v-cloak>
                                        <option value="0" selected>选择品牌</option>
                                        <option :value="item.id" v-for="(item,index) in brandList">{{item.name}}</option>
                                    </select>
                                </td>
                            </tr>
                        	<tr>
                            	<td class="field-name">{:strtoupper(lang("product_name"))}<span class="required"></span></td>
                                <td><input type="text" class="form-control" v-model="checkRead.pro_name"></td>
                            </tr>
                        	<tr>
                            	<td class="field-name">{:strtoupper(lang("introduction"))}</td>
                                <td><input type="text" class="form-control"  v-model="checkRead.prodesc"></td>
                            </tr>
                        	<tr v-cloak>
                            	<td class="field-name">所属分类</td>
                                <td>{{checkRead.cateChild}}</td>
                            </tr>
                        </table>
               
                    </div>
                </div>
            	<table class="table table-striped table-hover ntTable" v-cloak>
                	<thead>
                    	<tr>
                            <th>{:strtoupper(lang("model"))}<span class="required"></span></th>
                            <th style="width: 100px;">{:strtoupper(lang("package"))}</th>
                            <th v-for="(featureitem,index) in checkRead_role[0].feature">{{featureitem.name}}</th>
                            <th style="width: 100px;">{:strtoupper(lang("box_measure"))}</th>
                            <th>{:strtoupper(lang("description"))}</th>
                            <th>{:strtoupper(lang('status'))}</th>
                            <th>{:strtoupper(lang('operate'))}</th>
                        </tr>
                    </thead>
                    <tbody>
                    	<tr v-for="(item,index) in checkRead_role" v-if="index!=0">
                        	<td>
	                            <input type="text" class="form-control" v-model="checkRead_role[index].model">
                            </td>
                            <td align="center">
                                <input type="text" class="form-control" v-model="checkRead_role[index].package_qty">
                            </td>
                            <td v-for="(featureitem,index) in checkRead_role[index].feature">{{featureitem.value}}</td>
                            <td style="min-width: 150px;">
                                <input type="text" class="form-control" v-model="checkRead_role[index].ctn_size">
                            </td>
                            <td>
	                            <input type="text" class="form-control" v-model="checkRead_role[index].ctn_note">
                            </td>
                            <td>{{checkRead_role[index].status}}</td>
                            <td class="text-right">
                            	<a href="javascript:;" class='btn btn-sm btn-default' @click="removefun(index)"><span class="glyphicon glyphicon-remove"></span> {:strtoupper(lang('delete'))}</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                	<span class="glyphicon glyphicon-remove"></span>{:strtoupper(lang('close'))}
                </button>
                <button type="button" class="btn btn-primary" style="padding-left:24px;padding-right:24px" @click="returnfun('back')">
                	<span class="glyphicon glyphicon-floppy-saved"></span>{:strtoupper(lang("return_to_list_after_saving"))}
                </button>
                <button type="button" class="btn btn-primary" @click="returnfun('edit')" style="padding-left:24px;padding-right:24px">
                	<span class="glyphicon glyphicon-floppy-save"></span>保存后编辑产品详情
                </button>
            </div>
            </div>
<script>
new Vue({
    el:'#mainopen',
    data:()=>({
        checkRead:{},
        checkRead_role:[{feature:[]}],
        brandList:[],
        langs:[]
    }),
    methods:{
        getdata(){
            $.ajax({
                url:"/admin/product/proCopy",
                data:{
                    request:'ajax',
                    id:this.$refs.didput.value
                },
                type:"post",
                success:(data)=>{
                    data = JSON.parse(data)
                    this.checkRead=data.checkRead
                    this.brandList=data.brandList
                    this.checkRead_role[0]=data.checkRead_role[0]
                    data.checkRead_role.forEach(element => {
                        this.checkRead_role.push(element)
                    });
                }
            })
        },
        removefun(index){
                this.checkRead_role.splice(index,1)
        },
        returnfun(if_edit){
            var data={}
            data.checkRead=this.checkRead
            data.checkRead_role=this.checkRead_role.filter((item,index)=>{
                return index!=0
            })
            data.checkRead_role.forEach((item)=>{
                $.ajax({
                    url:'/admin/api/getProcharCodebar',
                    type:'post',
                    success:(data)=>{
                            item.codebar=data
                    }
                })
            })            
            $.ajax({
                url:'/admin/product/proCopy?request=insert',
                type:'post',
                data,
                success:(data)=>{
                    data = JSON.parse(data)
                    if(data.status==1){
                        change_mes_type('.alert',data.status)
                        $('.alert').show()
                        $('.alert p').html('*'+data.msg+'<br>')
                        if(if_edit=='edit'){
                            location.href="/admin/product/productEdit?request=edit&id="+data.pro_id
                        }else{
                            $('#prosCopy').modal('hide');
                        }
                    }else{
                        change_mes_type('.modal-body .alert',data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*'+data.msg+'<br>')
                    }
                }
            }) 
        }
    },
    mounted(){
        $.ajax({
            url:'/admin/api/getLangType',
            type:'post',
            //async:false,
            success:data=>{
                this.langs = JSON.parse(data)
            }
        })
        this.getdata()
    }
})
</script>
